#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2021-12-10 17:35
# @Author : huabao.tan
# @File : demo3.py
# @Software: PyCharm

class Person(object):

    def __init__(self, name, age):
        self.name = name
        self.age = age
        self.__life_var = 100


    def get_life_val(self):
        print("总生命值有", self.__life_var)

    def got_attack(self):
        self.__life_var -= 20
        print("被攻击了， 生命值减少20， 生命值剩余%s"%self.__life_var)
        return self.__life_var

class Dog(object):

    def sound(self):
        print("dog")

class Cat(object):

    def sound(self):
        print("cat")

def make_sound(animal_type):
    animal_type.sound()

d = Dog()
c = Cat()

class Document:
    def __init__(self, name):
        self.name = name

    def show(self):
        raise NotImplementedError("Subclas must implement abstract method")

class Pdf(Document):
    def show(self):
        return "Show pdf contents!"

class Word(Document):
    def show(self):
        return "Show word contents"

p = Pdf("sex.pdf")



class Debug(object):

    def __init__(self, name):
        self.name = name

    @classmethod
    def eat(self):
        print(self)
        print("%s is eating"%self.__name__)

class Student(object):
    student_number = 0

    @classmethod
    def __init__(self, name):
        self.name = name
        self.student_number += 1
        print("生成了一个新学生:", name, self.student_number)


s1 = Student("mzt")
s2 = Student('lfz')
s3 = Student('bfm')